Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:58

0001 //===- llvm/IR/DbgVariableFragmentInfo.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 //
0009 // Helper struct to describe a fragment of a debug variable.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 #ifndef LLVM_IR_DBGVARIABLEFRAGMENTINFO_H
0013 #define LLVM_IR_DBGVARIABLEFRAGMENTINFO_H
0014 
0015 #include <cstdint>
0016 
0017 namespace llvm {
0018 struct DbgVariableFragmentInfo {
0019   DbgVariableFragmentInfo() = default;
0020   DbgVariableFragmentInfo(uint64_t SizeInBits, uint64_t OffsetInBits)
0021       : SizeInBits(SizeInBits), OffsetInBits(OffsetInBits) {}
0022   uint64_t SizeInBits;
0023   uint64_t OffsetInBits;
0024   /// Return the index of the first bit of the fragment.
0025   uint64_t startInBits() const { return OffsetInBits; }
0026   /// Return the index of the bit after the end of the fragment, e.g. for
0027   /// fragment offset=16 and size=32 return their sum, 48.
0028   uint64_t endInBits() const { return OffsetInBits + SizeInBits; }
0029 
0030   /// Returns a zero-sized fragment if A and B don't intersect.
0031   static DbgVariableFragmentInfo intersect(DbgVariableFragmentInfo A,
0032                                            DbgVariableFragmentInfo B) {
0033     // Don't use std::max or min to avoid including <algorithm>.
0034     uint64_t StartInBits =
0035         A.OffsetInBits > B.OffsetInBits ? A.OffsetInBits : B.OffsetInBits;
0036     uint64_t EndInBits =
0037         A.endInBits() < B.endInBits() ? A.endInBits() : B.endInBits();
0038     if (EndInBits <= StartInBits)
0039       return {0, 0};
0040     return DbgVariableFragmentInfo(EndInBits - StartInBits, StartInBits);
0041   }
0042 };
0043 } // end namespace llvm
0044 
0045 #endif // LLVM_IR_DBGVARIABLEFRAGMENTINFO_H